package com.blog.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blog.entity.SysSensitive;
import com.blog.mapper.SysSensitiveMapper;
import com.blog.service.SysSensitiveService;
import com.blog.util.sensitive.SensitiveWordUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author cgx
 * @Date 2022/8/15 10:36
 */
@Service
public class SysSensitiveServiceImpl extends ServiceImpl<SysSensitiveMapper, SysSensitive> implements SysSensitiveService {

    @Resource
    SysSensitiveMapper sysSensitiveMapper;

    @Override
    public boolean filterSensitive(String comment) {
        Set<String> sensitiveWords = sysSensitiveMapper.querySensitiveWord();
        return SensitiveWordUtil.contains(sensitiveWords, comment);
    }

    @Override
    public Set<String> listSensitiveWords() {
        return sysSensitiveMapper.querySensitiveWord();
    }

    @Override
    public List<Map<String, Object>> tableList(String sensitiveWord,String createPeople) {
        return sysSensitiveMapper.tableList(sensitiveWord,createPeople);
    }

}
